package cn.walls1717.wallsmall.product.service.impl;

import cn.walls1717.wallsmall.common.utils.PageUtils;
import cn.walls1717.wallsmall.common.utils.Query;
import cn.walls1717.wallsmall.product.dao.SkuImagesDao;
import cn.walls1717.wallsmall.product.entity.SkuImagesEntity;
import cn.walls1717.wallsmall.product.service.SkuImagesService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service("skuImagesService")
public class SkuImagesServiceImpl extends ServiceImpl<SkuImagesDao, SkuImagesEntity> implements SkuImagesService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<SkuImagesEntity> page =
            this.page(new Query<SkuImagesEntity>().getPage(params), new QueryWrapper<SkuImagesEntity>());

        return new PageUtils(page);
    }

    /**
     * 根据skuId查询sku图片
     *
     * @param skuId skuId
     * @return sku图片集合
     */
    @Override
    public List<SkuImagesEntity> listSkuImagesBySkuId(Long skuId) {
        return lambdaQuery().eq(SkuImagesEntity::getSkuId, skuId).list();
    }

}